<template>
    <div>
        <div>{{num | number}}</div>
        <el-button @click="refresh">点我</el-button>
        <!-- `mapGetters` 引入的state-->
        <h3>{{sysUser}}</h3>
    </div>
</template>


<script>
import { mapState, mapGetters,mapMutations,mapActions } from "vuex";

export default {
    data() {
        return {
            num: "0",
        };
    },

    computed: {
        //通过`store.js` 的`getters`暴露出的属性
        ...mapState('login',{
            sysUser:(state)=>state.sysUser.name
        })
    },
    methods: {
        refresh() {
            let name = "小红"
            this.$store.dispatch("login/nameLoad", name);
        },
    },
    filters: {
        number(value) {
            var toFixedNum = Number(value).toFixed(3);
            var realVal = toFixedNum.substring(
                0,
                toFixedNum.toString().length - 1
            );
            return realVal;
        },
    },
};
</script>